package com.bdqn.crm.exception;
import jakarta.servlet.UnavailableException;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(UnavailableException.class)
    public ModelAndView unauthorizedException(HttpServletRequest request, Exception e){
        ModelAndView mv = new ModelAndView("403");
        mv.addObject("exception",e);
        mv.addObject("url",request.getRequestURL());
        return mv;
    }
}
